package Tools;

import Figures.Figure;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * 类功能描述：
 *图形容器对象,用来存储从面板上创建的多个图形及其属性
 * @author lix
 * @date 2023/12/28
 */

public class FiguresContainer implements Serializable {
    public void setStatusManager(StatusManager statusManager) {
        this.statusManager = statusManager;
    }

    public   StatusManager statusManager;
    public List<Figure> getFigures() {
        return figures;
    }

    public List<Figure> figures = new ArrayList<Figure>();     //保存已经添加的图形

    private int index;                  //保存索引值

    public Figure getTemp_figure() {
        return temp_figure;
    }

    public void setTemp_figure(Figure temp_figure) {
        this.temp_figure = temp_figure;
    }

    private Figure temp_figure;         //暂时形状

    public void addFigure(Figure figure){//添加图形操作
        if(statusManager.isCreatingFigure()) figures.add(figure);
    }

    public void removeFigure(Figure temp){//清除指定图形
        figures.remove(temp);
    }


    public void clearContainer(){//清空容器
        if(statusManager.isClearingPanel()){
            figures.clear();
            temp_figure = null;
        };
    }



    public boolean isEmpty(){
        return figures == null;
    }




}
